package com.awangyh.jdk8.thread;

/**
 * Created by Administrator on 2017/5/16.
 */
public class InstanceVariableDemo implements Runnable {

    private int i;

    private void add() {
        int i=0;
        for (int j = 0; j<= 10; j++){
            i += j;
            //System.out.println(Thread.currentThread().getName() + " - add for: " + i);

        }

        System.out.println(Thread.currentThread().getName() + " - add: " + i);
    }

    public static void main(String[] args) {

        InstanceVariableDemo demo = new InstanceVariableDemo();
        Thread t1 = new Thread(demo);
        Thread t2 = new Thread(demo);
        t1.start();
        t2.start();

    }

    @Override
    public void run() {
        add();

    }
}
